package java_1_12.book_management.user;

import java_1_12.book_management.operation.IOperation;
import java_1_12.book_management.operation.impl.*;

import java.util.Scanner;

//普通用户类
public class NormalUser extends User{
    private Scanner scanner=new Scanner(System.in);
    public NormalUser(String name){
        this.name=name;
        this.operations=new IOperation[]{
                //查询书籍列表
                new DisplayAllBooks(),
                //查询书籍
                new FindOperation(),
                //借书
                new BorrowOperation(),
                //还书
                new ReturnOperation(),
                //扩展一个新的测试权限、
                new TestOperation(),
        };
    }

    /**
     * 此处返回值标识用户选择了菜单中哪个选项
     * @return
     */
    @Override
    public int menu() {
        System.out.println("----------------------------------");
        System.out.println("欢迎"+this.name+"登录图书管理系统");
        System.out.println("1.显示当前书籍列表");
        System.out.println("2.查询书籍");
        System.out.println("3.借阅书籍");
        System.out.println("4.归还书籍");
        System.out.println("5.测试权限");
        System.out.println("-1.退出");
        System.out.println("请输入您的选择");
        int choice=scanner.nextInt();
        if(choice==-1){
            //关闭输入
            scanner.close();
        }
        System.out.println("--------------------------------------");
        return choice;
    }
}
